package com.xthh.esl;

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

import android.content.Context;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileUtil {
    private static final String TAG = "FileUtil";
    private static String FILE_NAME = "";

    public FileUtil() {
    }

    public static String getFileName(Context context) {
        String path = context.getExternalFilesDir((String)null).getPath();
        String address = "image_apdu.txt";
        return FILE_NAME = path + '/' + address;
    }

    public static boolean createTextFile(Context context, String fileName, String data) {
        try {
            File file = new File(getFileName(context));
            FileOutputStream fos;
            if (!file.exists()) {
                file.createNewFile();
                fos = new FileOutputStream(file);
                fos.write(data.getBytes());
                fos.flush();
                fos.close();
            } else {
                fos = new FileOutputStream(file, true);
                fos.write("\r\n".getBytes());
                fos.write(data.getBytes());
                fos.flush();
                fos.close();
            }

            return true;
        } catch (IOException var5) {
            Log.e("FileUtil", "Error creating file: " + var5.getMessage());
            return false;
        }
    }

    public static void deleteFile(Context context) {
        try {
            File file = new File(getFileName(context));
            if (file.exists()) {
                file.delete();
            }
        } catch (Exception var2) {
            Log.e("FileUtil", "Error creating file: " + var2.getMessage());
        }

    }
}
